import java.util.ArrayList;
import java.util.Random;

/**
 * 
 * @author Devin Wolanick
 * @Version 1.0
 * 
 * Shoe is a Collection of Decks
 */
public class Shoe implements CardStack{
	
	/**
	 * Variables
	 */
	private ArrayList<Card> shoeDeck = new ArrayList<Card>();
	
	/**
	 * Default Constructor with one Deck
	 */
	public Shoe(){
		Deck singleDeck = new Deck();
		while (!singleDeck.isEmpty())
			shoeDeck.add(singleDeck.drawCard());
	}
	
	/**
	 * Constructor for multiple Decks
	 * @param numberOfDecks Number Of Decks
	 */
	public Shoe(int numberOfDecks) {
		if (numberOfDecks<0) {
			System.out.println("Invalid Construction of Shoe");
			System.exit(1);
		}
		for (int i=0; i<numberOfDecks; i++) {
			Deck singleDeck = new Deck();
			while (!singleDeck.isEmpty())
				shoeDeck.add(singleDeck.drawCard());
		}
	}
	
	/**
	 * Returns Deck Size
	 * @return Deck Size
	 */
	public int getSize() {
		return shoeDeck.size();
	}
	
	/**
	 * Draws Top Card
	 * @return Top Card
	 */
	public Card drawCard() {
		return shoeDeck.remove(0);
	}
	
	/**
	 * Returns if Deck is Empty
	 * @return Return boolean
	 */
	public boolean isEmpty() {
		return shoeDeck.isEmpty();
	}
	
	/**
	 * Kills Top Card
	 */
	public void killCard() {
		shoeDeck.remove(0);
	}
	
	/**
	 * Shuffles the Deck
	 */
	public void shuffle() {
		ArrayList<Card> shuffledDeck = new ArrayList<Card>();
		Random generator = new Random();
		while (!shoeDeck.isEmpty()) {
			int r = generator.nextInt(shoeDeck.size());
			shuffledDeck.add(shoeDeck.remove(r));
		}
		this.shoeDeck = shuffledDeck;
	}
}